import { defineStore } from 'pinia'

const useUser = defineStore('user', {
  state: () => {
    return {
      userInfo: {},
    }
  },
  persist: {
    storage: sessionStorage,
    paths: ['userInfo'],
  },
  getters: {
    userId: (state) => state.userInfo.userId,
    dept: (state) => state.userInfo.dept,
    nickName: (state) => state.userInfo.nickName,
  },
  actions: {
    setUserInfo(userInfo) {
      this.userInfo = userInfo
    },
  },
})

export default useUser
